package lm.concurrency.pattern.prowithcon;

import lm.concurrency.util.Sleeper;

public class TestDemo {

    public static void main(String[] args) {
        MessageQueue queue = new MessageQueue(2);

        for (int i = 0; i < 3; i++) {
            int id = i;
            new Thread(() -> {
                queue.put(new Message(id , "值"+id));
            }, "生产者" + i).start();
        }

        new Thread(() -> {
            while(true) {
                Sleeper.sleep(1);
                Message message = queue.take();
            }
        }, "消费者").start();
    }

}

